package com.mxpio.erp.common.oa.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpio.erp.common.jpa.policy.ResCodeGeneratorPolicy;
import com.mxpioframework.filestorage.entity.MxpioFileInfo;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;
import com.mxpioframework.security.entity.Dept;
import com.mxpioframework.security.entity.User;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_OA_INVOICE")
@Schema(description="请款单")
public class OaInvoice extends BaseEntity {
    @Id
    @Column(name = "BIZ_NO_", updatable = false)
    @Generator(policy = ResCodeGeneratorPolicy.class)
    @Schema(description = "请款单编号")
    private String bizNo;

    @Column(name = "REASON_",columnDefinition = "TEXT")
    @Schema(description = "请款事由")
    private String reason;

    @Column(name = "MONEY_")
    @Schema(description = "请款金额")
    private BigDecimal money;

    @Column(name = "CH_MONEY_")
    @Schema(description = "请款金额(大写)")
    private String chMoney;

    @Column(name = "COLLECTION_USER_ID_")
    @Schema(description = "领款人")
    private String collectionUserId;

    @Column(name = "COLLECTION_BANK_")
    @Schema(description = "领款银行")
    private String collectionBank;

    @Column(name = "COLLECTION_NUMBER_")
    @Schema(description = "领款账号")
    private String collectionNumber;

    @Column(name = "APPLY_ID_")
    @Schema(description = "申请人")
    @Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
    private String applyId;

    @Column(name = "APPLY_USER_DEPT_ID_")
    @Schema(description = "申请人部门")
    @Dict(dicCode = "deptCode", dicEntity = Dept.class, dicText = "deptName")
    private String applyUserDeptId;

    @Column(name = "APPLICANTS_")
    @Schema(description = "申请单位")
    @Dict(dicCode = "MB_ERP_OA_REIMBURSEMENT_APPLICANTS")
    private String applicants;

    @Column(name = "APPLICANTS_ABBR_")
    @Schema(description = "申请单位(缩写)")
    private String applicantsAbbr;


    @Column(name = "ORG_DESC_")
    @Schema(description = "一级部门描述")
    private String orgDesc;

    /**申请时间*/
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @Schema(description = "申请时间")
    @Column(name = "APPLY_TIME_")
    private Date applyTime;

    @Column(name = "RF_TYPE_")
    @Schema(description = "请款方式")
    @Dict(dicCode = "MB_ERP_OA_INVOICE_TYPE") //10现金 20 转支 30汇票
    private String rfType;

    @Column(name = "ORDER_STATUS_")
    @Schema(description = "工单状态") //10新增 20审核中 30已完成 40已关闭
    @Dict(dicCode = "MB_ERP_OA_INVOICE_ORDER_STATUS")
    private String orderStatus;

    @Schema(description = "图片")
    @Column(name = "FILE_",columnDefinition = "TEXT")
    @Dict(dicCode = "fileNo", dicEntity = MxpioFileInfo.class, dicText = "fileName")
    private String file;

    @Column(name = "FILE_NO_",columnDefinition = "TEXT")
    @Schema(description = "附件")
    @Dict(dicCode = "fileNo", dicEntity = MxpioFileInfo.class, dicText = "fileName")
    private String fileNo;

    /**审批状态*/
    @Column(name = "BPMN_STATUS_")
    @Schema(description = "审批状态")
    @Dict(dicCode = "ERP_COMMON_BPMN_STATUS")
    private String bpmnStatus;

    /**审批实例ID*/
    @Column(name = "PROCESS_INSTANCE_ID_")
    @Schema(description = "审批实例ID")
    private String processInstanceId;

    @Column(name = "MEMO_")
    @Schema(description = "备注")
    private String memo;

    @Transient
    @Schema(description = "是否撤销审批")
    @Dict(dicCode = "ERP_COMMON_YESNO") //0否 1是
    private String revoke;
}
